package com.woniuxy.controller;


import com.woniuxy.pojo.User;
import com.woniuxy.service.UserService;
import com.woniuxy.util.TreeNode;
import com.woniuxy.util.TreeNodeBuilder;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/index.do")
    public String index(){
        return "index";
    }

    @ResponseBody
    @RequestMapping(value = "/initIndexMenu.do")
    public List<TreeNode> initIndexMenu(){
        Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession();
        User user = (User) session.getAttribute("USER_SESSION");
        List<TreeNode> treeNodes = userService.selectMenusByUsid(user.getId());
        return treeNodes;
    }

    @RequestMapping(value = "/User_Management.do")
    public String toUserManager() {
        return "user/userList";
    }

    @RequestMapping(value = "/toUserAddPage.do")
    public String toUserAddPage() {
        return "user/userAdd";
    }

    @RequestMapping(value = "/toUserEidtPage.do")
    public String toUserEditPage() {
        return "user/userEdit";
    }

    @RequestMapping(value = "/toUserRolePage.do")
    public String toUserRolePage() {
        return "user/userRole";
    }

    @RequestMapping(value = "/Role_Management.do")
    public String toRoleManager() {
        return "role/roleList";
    }

    @RequestMapping(value = "/toDrvingRecordManager.do")
    public String toDrvingRecordManager() {
        return "drvingRecord/drvingRecordList";
    }

    @RequestMapping(value = "/toDrvingRecordAddPage.do")
    public String toDrvingRecordAddPage(){
        return "drvingRecord/drvingRecordAdd";
    }

    @RequestMapping(value = "/todrvingRecordEditPage.do")
    public String todrvingRecordEditPage(){
        return "drvingRecord/drvingRecordEdit";
    }

    @RequestMapping(value = "/todrvingRecordAllPage.do")
    public String todrvingRecordAllPage(){
        return "drvingRecord/drvingRecordAll";
    }

    @RequestMapping(value = "/toRefuelingRecordManager.do")
    public String toRefuelingRecordManager() {
        return "refuelingRecord/refuelingRecordList";
    }

    @RequestMapping(value = "/toRefuelingRecordAddPage.do")
    public String toRefuelingRecordAddPage(){
        return "refuelingRecord/refuelingRecordAdd";
    }

    @RequestMapping(value = "/toRefuelingRecordEditPage.do")
    public String toRefuelingRecordEditPage(){
        return "refuelingRecord/refuelingRecordEdit";
    }

    @RequestMapping(value = "/toRefuelingRecordAllPage.do")
    public String toRefuelingRecordAllPage(){
        return "refuelingRecord/refuelingRecordAll";
    }

    @RequestMapping(value = "/toRepairRecordManager.do")
    public String toRepairRecordManager() {
        return "repairRecord/repairRecordList";
    }

    @RequestMapping(value = "/toRepairRecordAddPage.do")
    public String toRepairRecordAddPage(){
        return "repairRecord/repairRecordAdd";
    }

    @RequestMapping(value = "/toRepairRecordEditPage.do")
    public String toRepairRecordEditPage(){
        return "repairRecord/repairRecordEdit";
    }

    @RequestMapping(value = "/toRepairRecordAllPage.do")
    public String toRepairRecordAllPage(){
        return "repairRecord/repairRecordAll";
    }

    @RequestMapping(value = "/toFeesManagerManager.do")
    public String toFeesManagerManager() {
        return "feesManager/feesManagerList";
    }

    @RequestMapping(value = "/toFeesManagerAddPage.do")
    public String toFeesManagerAddPage(){
        return "feesManager/feesManagerAdd";
    }

    @RequestMapping(value = "/toFeesManagerEditPage.do")
    public String toFeesManagerEditPage(){
        return "feesManager/feesManagerEdit";
    }

    @RequestMapping(value = "/toFeesManagerAllPage.do")
    public String toFeesManagerAllPage(){
        return "feesManager/feesManagerAll";
    }

    @RequestMapping(value = "/toMaintainRecordManager.do")
    public String toMaintainRecordManager() {
        return "maintainRecord/maintainRecordList";
    }

    @RequestMapping(value = "/toMaintainRecordAddPage.do")
    public String toMaintainRecordAddPage(){
        return "maintainRecord/maintainRecordAdd";
    }

    @RequestMapping(value = "/toMaintainRecordEditPage.do")
    public String toMaintainRecordEditPage(){
        return "maintainRecord/maintainRecordEdit";
    }

    @RequestMapping(value = "/toMaintainRecordAllPage.do")
    public String toMaintainRecordAllPage(){
        return "maintainRecord/maintainRecordAll";
    }

    @RequestMapping(value = "/toPeccancyRecordListPage.do")
    public String toPeccancyRecordListPage() {
        return "peccancyRecord/peccancyRecordList";
    }

    @RequestMapping(value = "/toPeccancyRecordAddPage.do")
    public String toPeccancyRecordAddPage() {
        return "peccancyRecord/peccancyRecordAdd";
    }

    @RequestMapping(value = "/toPeccancyRecordEditPage.do")
    public String toPeccancyRecordEditPage() {
        return "peccancyRecord/peccancyRecordEdit";
    }

    @RequestMapping(value = "/toPeccancyRecordDetailPage.do")
    public String toPeccancyRecorDetaillPage() {
        return "peccancyRecord/peccancyRecordDetail";
    }

    @RequestMapping(value = "/toCarDetailPage.do")
    public String toCarDetaillPage() {
        return "car/CarDetail";
    }

    @RequestMapping(value = "/toCurrentUnitDetailPage.do")
    public String toCurrentUnitDetailPage() {
        return "currentUnit/currentUnitDetail";
    }

    @RequestMapping(value = "/toAccidentRecordListPage.do")
    public String toAccidentRecordListPage() {
        return "accidentRecord/accidentRecordList";
    }

    @RequestMapping(value = "/toAccidentRecordAddPage.do")
    public String toAccidentRecordAddPage() {
        return "accidentRecord/accidentRecordAdd";
    }

    @RequestMapping(value = "/toAccidentRecordEditPage.do")
    public String toAccidentRecordEditPage() {
        return "accidentRecord/accidentRecordEdit";
    }

    @RequestMapping(value = "/toAccidentRecordDetailPage.do")
    public String toAccidentRecordDetailPage() {
        return "accidentRecord/accidentRecordDetail";
    }

    @RequestMapping(value = "/toInspectionRecordListPage.do")
    public String toInspectionRecordListPage() {
        return "inspectionRecord/inspectionRecordList";
    }

    @RequestMapping(value = "/toAssignRightPage.do")
    public String toAssignRightPage() {
        return "role/assignRight";
    }

    @RequestMapping(value = "/Sys_Dictionary.do")
    public String toDictionaryManager(){
        return "dictionary/dictionaryList";
    }

    @RequestMapping(value = "/toDicAddPage.do")
    public String toDicAddPage() {
        return "dictionary/dictionaryAdd";
    }

    @RequestMapping(value = "/toDicEidtPage.do")
    public String toDicEditPage() {
        return "dictionary/dictionaryEdit";
    }

    @RequestMapping(value = "/Modify_Password.do")
    public String toUpdatePassword() {
        return "user/userPwdChange";
    }

    @RequestMapping(value = "/toReport_1.do")
    public String toReportOne() {
        return "echarts/barGraph";
    }

    @RequestMapping(value = "/toReport_2.do")
    public String toReportTwo() {
        return "echarts/pieChart";
    }

    @RequestMapping(value = "/toInspectionRecordAddPage.do")
    public String toInspectionRecordAddPage() {
        return "inspectionRecord/inspectionRecordAdd";
    }

    @RequestMapping(value = "/toInspectionRecordEditPage.do")
    public String toInspectionRecordEditPage() {
        return "inspectionRecord/inspectionRecordEdit";
    }

    @RequestMapping(value = "/toInspectionRecordDetailPage.do")
    public String toInspectionRecordDetailPage() {
        return "inspectionRecord/inspectionRecordDetail";
    }

    @RequestMapping(value = "/toInsuranceRecordListPage.do")
    public String toInsuranceRecordListPage() {
        return "insuranceRecord/insuranceRecordList";
    }

    @RequestMapping(value = "/toInsuranceRecordDetailPage.do")
    public String toInsuranceRecordDetailPage() {
        return "insuranceRecord/insuranceRecordDetail";
    }

    @RequestMapping(value = "/toInsuranceRecordAddPage.do")
    public String toInsuranceRecordAddPage() {
        return "insuranceRecord/insuranceRecordAdd";
    }

    @RequestMapping(value = "/toInsuranceRecordEditPage.do")
    public String toInsuranceRecordEditPage() {
        return "insuranceRecord/insuranceRecordEdit";
    }

    @RequestMapping(value = "/toExpireRemindListPage.do")
    public String toExpireRemindListPage() {
        return "expireRemind/expireRemindList";
    }

    @RequestMapping(value = "/toLoginOut.do")
    public String loginOut() {
        Subject subject = SecurityUtils.getSubject();
        Session session=subject.getSession();
        session.removeAttribute("USER_SESSION");
        subject.logout();
        return "login";
    }

    @RequestMapping(value = "/toUserDetailsPage.do")
    public String toUserDetailsPage() {
        return "user/userDetails";
    }

    @RequestMapping(value = "/toUserInfoPage.do")
    public String toUserInfoPage() {
        return "user/userInfo";
    }
}
